gistfile1.txt define(function (require) { var ClassEvent = require("./classevent"); var Extend = require("./extend"); //var $ = require("jquery"); /** * 用于生成只有两级的可折叠的菜单 */ function AccordionMenu(setting) { Clas
define(function (require) { var ClassEvent = require("./classevent"); var Extend = require("./extend"); //var $ = require("jquery"); /** * 用于生成只有两级的可折叠的菜单 */ function AccordionMenu(setting) { ClassEvent.call(this); this.setting = setting; this.accordin = null; } AccordionMenu.prototype.Init = function () { this.accordin = this.initAccordin(); return this; } AccordionMenu.prototype.GetAccordionDom = function () { return this.accordin; } AccordionMenu.prototype.CloseItem = function (parm) { this.accordin.accordion("close", parm); } AccordionMenu.prototype.OpenItem = function (parm) { this.accordin.accordion("open", parm); } /** * 获取展开的item */ AccordionMenu.prototype.GetExtendData = function () { return this.accordin.find($.fn.accordion.settings.selector.title + "." + $.fn.accordion.settings.className.active).data("accordinitemtitle"); } AccordionMenu.prototype.GetExtendContent = function () { return this.accordin.find($.fn.accordion.settings.selector.content + "." + $.fn.accordion.settings.className.active) } AccordionMenu.prototype.GetExtendTitle = function () { return this.accordin.find($.fn.accordion.settings.selector.title + "." + $.fn.accordion.settings.className.active) } //onOpening : function(){}, // callback before open animation //onOpen : function(){}, // callback after open animation //onClosing : function(){}, // callback before closing animation //onClose : function(){}, // callback after closing animation //onChange : function(){}, // callback after closing or opening animation AccordionMenu.prototype.initAccordin = function () { var self = this; var acc = $("
///gistfile3.txt/// /// /// /// /// define(function (require) { var ClassEvent, ScrollNav,Extend, ScrollActionTypeManager, AccordionMenu;//模块实现需要的变量依赖 ClassEvent = require("./classevent"); ScrollNav = require("./app_nav"); Extend = require("./extend"); ScrollActionTypeManager = require("./scrollactiontypemanager"); AccordionMenu = require("./accordionmenu"); var AccordionMenuNavigation = function () { function accordionmenunavigation(setting) { var _self = this; ClassEvent.call(this); this.setting = setting; this.InitAccordionMenu(); } accordionmenunavigation.prototype.InitAccordionMenu = function () { var _self = this; this.AccordionMenu = new AccordionMenu({ Data: this.setting.Data }); this.AccordionMenu.Init(); this.AccordionMenu.RegistEvent("Opening", function () { _self.openEvent.apply(_self, arguments); }, this); this.AccordionMenu.RegistEvent("LinkClick", function () { _self.itemClickEvent.apply(_self, arguments); }, this); $(this.setting.NavContainer).append(this.AccordionMenu.GetAccordionDom()); } accordionmenunavigation.prototype.openEvent = function (accor,event,_self) { event.dom.children().first().find("a").children().click(); } accordionmenunavigation.prototype.itemClickEvent = function (accor,event,_self) { $("#" + this.setting.InfoContainer).children().hide(); event.dom.parentsUntil("ul").parent("ul").find("a").removeClass("active"); event.dom.addClass("active"); var func = ScrollActionTypeManager.GetActionType(event.data.Action || "DataTable"); if (typeof func === "function") { func({ DataManager: this.setting.DataManager, Container: this.setting.InfoContainer,//内容节点 ScrollControl: this,//预留 作用不大 NavItem: event.parent,//nav item SubItem: event.data,//init subitem }) } } //accordionmenunavigation.prototype.scrollNavChange = function (scroll, event, control) { // var blocks = event.item; // $("#" + control.setting.InfoContainer).children().each(function () { // $(this).hide(); // });//.html(""); // $("#" + control.setting.InfoContainer).css("padding-bottom", $("#" + control.setting.InfoContainer).parent().height());//先进行补白操作,防止宽度出现错误 // //if (event.item.DefaultAction) { // if (true) { // //进行默认的处理 有用户自己进行处理 // if (blocks.Data && blocks.Data.length > 0) { // for (var i = 0; i < blocks.Data.length; i++) { // var func = ScrollActionTypeManager.GetActionType(blocks.Data[i].Action || "DataTable"); // if (typeof func === "function") { // func({ // DataManager: control.setting.DataManager, // Container: control.setting.InfoContainer,//内容节点 // ScrollControl: control,//预留 作用不大 // ScrollSpy: scroll,//预留 作用不大 // NavItem: event.item,//nav item // SubItem: blocks.Data[i]//init subitem // }) // } // } // } // } // control.ExcuteEvent("ScrollItemChange", control, event); //} accordionmenunavigation.prototype.Destroy = function () { this.ScrollNav.Destroy(); } accordionmenunavigation.prototype.Refresh = function () { //var containheight = $("#" + this.setting.InfoContainer).parent().height(); //var infoheight = $("#" + this.setting.InfoContainer).children(":visible").last().outerHeight(); ////高度不够进行补白 超出则去掉补白 //if (containheight > infoheight) { // $("#" + this.setting.InfoContainer).css("padding-bottom", containheight - infoheight); //} else { // $("#" + this.setting.InfoContainer).css("padding-bottom", 0); //} //this.ScrollNav.Refresh(); } //从新进行定位操作 accordionmenunavigation.prototype.LocaltionHash = function () { if (!/^\s{0,}$/.test(location.hash)) { var a = this.AccordionMenu.GetAccordionDom().find('a[href="' + location.hash + '"]'); a.parentsUntil("ul").parent("ul").parent("li").children().addClass("active"); a.click(); } } accordionmenunavigation.prototype.Open = function (index) { this.AccordionMenu.OpenItem(index); } Extend(accordionmenunavigation.prototype, ClassEvent.prototype); return accordionmenunavigation; }(); return AccordionMenuNavigation; });
/// /// /// define(function (require) { //var $ = require("jquery"); var ClassEvent = require("./classevent"); var AccordionMenu = require("./accordionmenu"); var Extend = require("./extend"); /** * 滚动监听 */ function ScrollNav(setting) { ClassEvent.call(this); this.accordinMenu = null; this.setting = setting; } ScrollNav.prototype.Init = function () { this.initAccordionMenu(); this.initScroll(); this.initEvent(); return this; } ScrollNav.prototype.initScroll = function () { $(this.setting.Listener).scrollspy({ target: this.setting.navContainer, offset: this.setting.offset }); } ScrollNav.prototype.initAccordionMenu = function () { var self = this; this.accordinMenu = new AccordionMenu({ Data: this.setting.Data }).Init(); this.accordinMenu.GetAccordionDom().addClass("nav"); $(this.setting.NavContainer).append(this.accordinMenu.GetAccordionDom()); } ScrollNav.prototype.initEvent = function () { var self = this; this.accordinMenu.RegistEvent("Opening", function (sender, event, option) { self.ExcuteEvent("ScrollNavOpen", self, { item: event.item }) }, this); this.accordinMenu.RegistEvent("LinkClick", function (sender, event, option) { self.ExcuteEvent("LinkClick", self, event) }, this); $(this.setting.Listener).on('activate.bs.scrollspy', function () { self.ExcuteEvent("Active", self, {}); }) } ScrollNav.prototype.Refresh = function () { $(this.setting.Listener).scrollspy('refresh'); $(this.setting.Listener).scrollspy('process'); } ScrollNav.prototype.RePosition = function () { //根据hash进行重新定位 this.setting.navContainer.find('a[href="' + location.hash + '"]'); } ScrollNav.prototype.Destroy = function () { this.accordinMenu.Destroy(); $(this.setting.Listener).scrollspy("destroy"); } ScrollNav.prototype.OpenItem = function (parm) { this.accordinMenu.OpenItem(); } ScrollNav.prototype.CloseItem = function (parm) { this.accordinMenu.CloseItem(arguments); } ScrollNav.prototype.GetExtendData = function () { return this.accordinMenu.GetExtendData(); } ScrollNav.prototype.GetActiveItemData = function () { return this.accordinMenu.GetExtendContent().children(".active").data("itemdata"); } ScrollNav.prototype = Extend({}, ClassEvent.prototype, ScrollNav.prototype); })