Created
May 22, 2012 15:18
-
-
Save ryankinal/2769712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void AddAccordionScript() | |
| { | |
| StringBuilder sb = new StringBuilder(); | |
| sb.AppendLine(" <script type='text/javascript'>"); | |
| sb.AppendLine(" var stop = false;"); | |
| sb.AppendLine(" $(\"#accordion h3\").click(function (event) {"); | |
| sb.AppendLine(" if (stop) {"); | |
| sb.AppendLine(" event.stopImmediatePropagation();"); | |
| sb.AppendLine(" event.preventDefault();"); | |
| sb.AppendLine(" stop = false;"); | |
| sb.AppendLine(" }"); | |
| sb.AppendLine(" });"); | |
| sb.AppendLine(" $(\"#accordion\")"); | |
| sb.AppendLine(" .accordion({"); | |
| sb.AppendLine(" header: \"> div > h3\""); | |
| sb.AppendLine(" })"); | |
| sb.AppendLine(" .sortable({"); | |
| sb.AppendLine(" axis: \"y\","); | |
| if (_context.Editable) | |
| sb.AppendLine(" handle: \"h3\","); | |
| else | |
| sb.AppendLine(" handle: \"h4\","); | |
| sb.AppendLine(" stop: function () {"); | |
| sb.AppendLine(" stop = true;"); | |
| sb.AppendLine(" },"); | |
| sb.AppendLine(" update: function () {"); | |
| sb.AppendLine(" var jsonData = \"{NewOrder:'\" + $(this).sortable(\"toArray\") + \"'}\";"); | |
| sb.AppendLine(" $.ajax({"); | |
| sb.AppendLine(" type: \"POST\","); | |
| sb.AppendLine(" url: \"CourseStructure.aspx/ReorderChapter\","); | |
| sb.AppendLine(" data: jsonData,"); | |
| sb.AppendLine(" dataType: \"json\","); | |
| sb.AppendLine(" contentType: \"application/json; charset=utf-8\","); | |
| sb.AppendLine(" error: function (XMLHttpRequest, textStatus, errorThrown) {"); | |
| sb.AppendLine(" alert(\"ERROR status:\" + textStatus + \" error:\" + errorThrown);"); | |
| sb.AppendLine(" },"); | |
| sb.AppendLine(" });"); | |
| sb.AppendLine(" }"); | |
| sb.AppendLine(" });"); | |
| sb.AppendLine(" $(\"#accordion\")"); | |
| sb.AppendLine(" .accordion ({"); | |
| if (_courseVersion == null) | |
| sb.AppendLine(" active: 0"); | |
| else | |
| sb.AppendFormat(" active: {0}", _courseVersion.SelectedIndex(_selectedChapterId)).AppendLine(); | |
| sb.AppendLine(" })"); | |
| sb.AppendLine(" jQuery('.headerName').click(function () {"); | |
| sb.AppendLine(" var contentPanelId = jQuery(this).attr('id');"); | |
| sb.AppendLine(" //alert(contentPanelId);"); | |
| sb.AppendLine(" });"); | |
| sb.AppendLine(" </script>"); | |
| litScriptAccordion.Text = sb.ToString(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment