/* * Script from NETTUTS.com [by James Padolsey] * @requires jQuery($), jQuery UI & sortable/draggable UI modules */ var iNettuts = { jQuery : $, settings : { columns : '.column', widgetSelector: '.widget', handleSelector: '.widget-head', contentSelector: '.widget-content', widgetDefault : { movable: true, removable: true, collapsible: true, editable: false, colorClasses : ['color-yellow', 'color-red', 'color-blue', 'color-white', 'color-orange', 'color-green'] }, widgetIndividual : { intro : { movable: true, removable: true, collapsible: true, editable: false } } }, init : function () { this.attachStylesheet('inettuts.js.css'); this.addWidgetControls(); this.makeSortable(); }, getWidgetSettings : function (id) { var $ = this.jQuery, settings = this.settings; return (id&&settings.widgetIndividual[id]) ? $.extend({},settings.widgetDefault,settings.widgetIndividual[id]) : settings.widgetDefault; }, addWidgetControls : function () { var iNettuts = this, $ = this.jQuery, settings = this.settings; $(settings.widgetSelector, $(settings.columns)).each(function () { var thisWidgetSettings = iNettuts.getWidgetSettings(this.id); if (thisWidgetSettings.removable) { $('CLOSE').mousedown(function (e) { e.stopPropagation(); }).click(function () { if(confirm('确定关闭该模块?')) { $(this).parents(settings.widgetSelector).animate({ opacity: 0 },function () { $(this).wrap('
').parent().slideUp(function () { $(this).remove(); }); }); } return false; }).appendTo($(settings.handleSelector, this)); } if (thisWidgetSettings.editable) { $('EDIT').mousedown(function (e) { e.stopPropagation(); }).toggle(function () { $(this).css({backgroundPosition: '-66px 0', width: '55px'}) .parents(settings.widgetSelector) .find('.edit-box').show().find('input').focus(); return false; },function () { $(this).css({backgroundPosition: '', width: ''}) .parents(settings.widgetSelector) .find('.edit-box').hide(); return false; }).appendTo($(settings.handleSelector,this)); $('